﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GS.Cricket.Service.Impl.NHibernate;

namespace GS.Cricket.Service.Impl
{
    public class MatchTeamService : IMatchTeamService
    {

        #region IMatchTeamService Members

        public int Add(Entities.MatchTeam matchTeam)
        {
            return (int)matchTeam.Add<Entities.MatchTeam>();
        }

        public void Update(Entities.MatchTeam matchTeam)
        {
            var existing = GetById(matchTeam.Id);
            if (existing != null)
            {
                matchTeam.Update<Entities.MatchTeam>();
            }
        }

        public void Delete(int matchTeamId)
        {
            var existing = (Entities.MatchTeam)matchTeamId.GetById<Entities.MatchTeam>();
            if (existing != null)
            {
                existing.Delete<Entities.MatchTeam>();
            }
        }

        public Entities.MatchTeam GetById(int matchTeamId)
        {
            return (Entities.MatchTeam)matchTeamId.GetById<Entities.MatchTeam>();
        }

        public IEnumerable<Entities.MatchTeam> GetAll()
        {
            return this.GetAll<Entities.MatchTeam>();
        }

        #endregion
    }
}
